<?php

/**
 * Description of Register
 *
 * @author Kam
 */
class Application_Form_User_Register extends My_Form {

    public function init() {
        $this->setTitle($this->translate('XXX_USER_REGISTER_FORM_TITLE'));
        $this->showLabels(false);
        
        $email = new Zend_Form_Element_Text('email');
        $email->setLabel(_('XXX_USER_REGISTER_FORM_EMAIL_LABEL'));
        $email->setAttrib('placeholder', $this->_('XXX_USER_REGISTER_FORM_EMAIL_LABEL'));
        $email->setRequired();
        $email->addValidator('EmailAddress');
        $email->addValidator(new My_Validate_RowExists('user', 'email'));
        $this->addElement($email);

        $pass = new Zend_Form_Element_Password('pass');
        $pass->setLabel(_('XXX_USER_REGISTER_FORM_PASS_LABEL'));
        $pass->setAttrib('placeholder', $this->_('XXX_USER_REGISTER_FORM_PASS_LABEL'));
        $pass->setRequired();
        $this->addElement($pass);
        
        $pass2 = new Zend_Form_Element_Password('pass2');
        $pass2->setLabel(_('XXX_USER_REGISTER_FORM_PASS_LABEL'));
        $pass2->setAttrib('placeholder', $this->_('XXX_USER_REGISTER_FORM_PASS_REPEAT_LABEL'));
        $pass2->setRequired();
        $pass2->addValidator('Identical', false, array('token' => 'pass'));
        $this->addElement($pass2);
        
        $regulationsUrl = '/regulations';
        $regulations = new Zend_Form_Element_MultiCheckbox('regulations');
        $regulations->setLabel(_('XXX_USER_REGISTER_FORM_REGULATIONS_LABEL'));
        $regulations->setMultiOptions(array(
            'accept_regulations' => $this->_('XXX_USER_REGISTER_FORM_REGULATIONS_CHECKBOX', array('url' => $regulationsUrl))
        ));
        $regulations->setAttrib('escape', false);
        $this->addElement($regulations);
        $regulations->setRequired();
        $this->addElement($regulations);

        $this->addSubmitElement()->setLabel(_('XXX_USER_REGISTER_FORM_BUTTON'));
    }

}

